package com.xjm.service.combine.impl;

import com.xjm.enums.HeadLineStatusEnum;
import com.xjm.model.bo.HeadLine;
import com.xjm.model.bo.ShopCategory;
import com.xjm.model.dto.MainPageInfoDTO;
import com.xjm.model.dto.Result;
import com.xjm.model.vo.Page;
import com.xjm.service.combine.HeadLineShopCategoryCombineService;
import com.xjm.service.solo.HeadLineService;
import com.xjm.service.solo.ShopCategoryService;
import org.myspringframework.core.annotation.Service;
import org.myspringframework.core.inject.annotation.Autowired;

import java.util.List;

/**
 * @author jaymin
 * 2020/11/7 2:51
 */
@Service
public class HeadLineShopCategoryCombineServiceImpl implements HeadLineShopCategoryCombineService {
    @Autowired
    private HeadLineService headLineService;
    @Autowired
    private ShopCategoryService shopCategoryService;

    @Override
    public Result<MainPageInfoDTO> getMainPageInfo() {
        // 1. 获取头条列表
        HeadLine headLine = HeadLine.builder().enableStatus(HeadLineStatusEnum.ON.getStatus()).build();
        Page headLinePage = Page.builder().page(1).pageSize(4).build();
        Result<List<HeadLine>> headLineResult = headLineService.getHeadlineList(headLine, headLinePage);
        // 2. 获取店铺类别列表
        Page shopCategoryPage = Page.builder().page(1).pageSize(100).build();
        Result<List<ShopCategory>> shopCategoryResult = shopCategoryService.getShopCategoryList(new ShopCategory(), shopCategoryPage);
        // 3. 参数合并
        Result<MainPageInfoDTO> result = mergeMainPageInfoResult(headLineResult, shopCategoryResult);
        return result;
    }

    private Result<MainPageInfoDTO> mergeMainPageInfoResult(Result<List<HeadLine>> headLineResult, Result<List<ShopCategory>> shopCategoryResult) {
        return null;
    }
}
